package com.fcbox.bypass;

import com.alibaba.fastjson.JSON;
import com.fcbox.uic.domain.user.UicUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;

import java.util.concurrent.TimeUnit;

/**
 * application
 * Created by 000498 on 2017/5/12.
 */
@SpringBootApplication
@Slf4j
public class Application implements CommandLineRunner {
	@Autowired
	RedisTemplate redisTemplate;
	@Override
	public void run(String... strings) throws Exception {
		//获取到redisTemplate
		ValueOperations opv = redisTemplate.opsForValue();
		Object aa;
		aa = opv.get("aa");
		log.info("*****************get-> {}", aa);
		opv.set("aa", "bb", 1, TimeUnit.MINUTES);
		aa = opv.get("aa");
		log.info("*****************set and get-> {}", aa);

		//配置redisTemplate
//		HashOperations oph = redisTemplate.opsForHash();
//		UicUser uicUser = (UicUser) oph.get("uic:user:56529356972916736", "baseUserInfo");
//		log.info("*****************uicUser:{}", JSON.toJSONString(uicUser));
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}
